package com.yfp.goods.api.factory;

import com.yfp.common.core.domain.R;
import com.yfp.goods.api.RemoteComboService;
import com.yfp.goods.domain.Combo;
import com.yfp.goods.domain.ComboGroupDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 
 * @version 1.0
 * @date 2024-07-13 14:25
 */
@Component
public class RemoteComboFallbackFactory implements FallbackFactory<RemoteComboService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteGoodsFallbackFactory.class);

    @Override
    public RemoteComboService create(Throwable cause) {
        log.error("combo服务调用失败:{}", cause.getMessage());
        return new RemoteComboService() {
            @Override
            public R<List<String>> getComboIds() {
                return R.fail("获取套餐列表失败：" + cause.getMessage());
            }
            @Override
            public R<List<ComboGroupDTO>> getGroupShelfComboList() {
                return R.fail("获取套餐列表失败：" + cause.getMessage());
            }

            @Override
            public R<List<Combo>> getComboByIds(List<String> comboIds) {
                return R.fail("获取套餐列表失败：" + cause.getMessage());
            }
        };
    }
}
